# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Llewelyn Trahaearn <WoefulDerelict at GMail dot com>
# Contributor: FadeMind <fademind at gmail dot com>
# Contributor: Maxime Gauduin <alucryd at archlinux dot org>
# Contributor: bitwave <aur at oomlu dot de>
# Contributor: willemw <willemw12 at gmail dot com>
# Contributor: Balló György <ballogyor+arch at gmail dot com>

pkgbase=libappindicator
pkgname=("${pkgbase}-gtk"{2,3})
_bzrtag=12.10.0
_bzrrev=298
pkgver=${_bzrtag}.r${_bzrrev}
pkgrel=3
pkgdesc='Allow applications to extend a menu via Ayatana indicators in Unity, KDE or Systray'
url='https://launchpad.net/libappindicator'
arch=('loong64' 'x86_64')
license=('LGPL2.1' 'LGPL3')
makedepends=('breezy' 'dbus-glib' 'gnome-common' 'gobject-introspection' 'gtk-doc' 'libdbusmenu-gtk'{2,3} 'vala')
options=('!emptydirs')
source=($pkgbase::bzr+https://code.launchpad.net/~indicator-applet-developers/libappindicator/trunk#revision=$_bzrrev)
sha512sums=('SKIP')
validpgpkeys=('6FC05581A37D71FCECE165DB5BE41E162CD6358E')  # Charles Kerr <charles.kerr@canonical.com>

prepare() {
  (cd ${pkgbase}
    NOCONFIGURE=1 ./autogen.sh
  )
  cp -ra ${pkgbase}{,-gtk2}
}

build() {
  msg2 'Building gtk3...'
  (cd ${pkgbase}
    ./configure --prefix=/usr \
      --sysconfdir=/etc \
      --localstatedir=/var \
      --with-gtk=3 \
      --enable-gtk-doc
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )

  msg2 'Building gtk2...'
  (cd ${pkgbase}-gtk2
    ./configure --prefix=/usr \
      --sysconfdir=/etc \
      --localstatedir=/var \
      --with-gtk=2 \
      --disable-introspection
    sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    make
  )
}

package_libappindicator-gtk2() {
  pkgdesc+=' (GTK+ 2 library)'
  depends=('libdbusmenu-gtk2')

  cd ${pkgbase}-gtk2
  make -j1 DESTDIR="${pkgdir}" install
}

package_libappindicator-gtk3() {
  pkgdesc+=' (GTK+ 3 library)'
  depends=('libdbusmenu-gtk3')

  cd ${pkgbase}
  make -j1 DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
